<?php
import('#/view.php');

class Controller
{
	private static $tpl_vars=array();
	
	public function action($controller, $action='show')
	{
		return Core::action($controller, $action);
	}
	
	public function assign($key, $value=null)
	{
		if(is_array($key))
		{
			self::$tpl_vars	=	array_merge(self::$tpl_vars, $key);
		}
		else
		{
			self::$tpl_vars[$key]	=	$value;
		}
		return $this;
	}
	public function get($key)
	{
		return empty(self::$tpl_vars[$key]) ? self::$tpl_vars[$key] : null;
	}
	
	public function display($_act=null, $_layout=null)
	{
		View::assign(self::$tpl_vars);
		View::display($_act, $_layout);
	}
	public function fetch($_act=null, $_layout=null)
	{
		View::assign(self::$tpl_vars);
		return View::fetch($_act, $_layout);
	}
	
	public function redirect($url)
	{
		header('location: '. ($url ? Lib::url($url) : WEB_ROOT.'/') );
		exit();
	}
	
}

?>